<template>
    <div class="lg_main">
        <div class="ksZwh" id="zwh" style="display:none"></div>
        <div class="lg_header">
            <span>&nbsp;</span>
        </div>
        <div class="lg_from">
            <div class="lg_from_left">
                <div class="shenfenz">
                    <span>准&emsp;考&emsp;证&emsp;号:</span>
                </div>
                <div class="zhenjian">
                    <span>有效身份证件号:</span>
                </div>
            </div>
            <div class="lg_from_right">
                <div class="shenfenz">
                    <input class="lg_input" type="text" id="zkzh" size="40" placeholder="请输入证件号码" ref="idCard" readonly/>
                </div>
                <div class="zhenjian">
                    <input class="lg_input" type="text" id="zjbm" size="40" placeholder="请输入身份证号码" ref="idNumber" readonly/>
                </div>
            </div>
            <div class="buttonk">
                <input type="button" class="buttonDl" onmouseout="this.className='buttonDl'" @click="joinExam"
                       onmouseover="this.className='buttonDlOnlie'" onmousedown="this.className='buttonDlDown'"
                       id="loginbtn"/>
                <input type="button" class="buttonCz" onmouseout="this.className='buttonCz'" @click="reset"
                       onmouseover="this.className='buttonCzOnlie'" onmousedown="this.className='buttonCzDown'"
                       id="resetbtn"/>
            </div>
        </div>
        <div class="" id="tishi" style="margin-top:-100px;margin-left:450px;font-weight:bold"></div>
        <div class="version"><span></span></div>
    </div>
</template>

<script type="text/ecmascript-6">
    import {examMixin} from "../mixins/mixin";
    import {ref} from 'vue';
    import {isIdCard} from '@/utils/common'

    export default {
        mixins: [examMixin],
        data() {
            return {
                exam: []
            }
        },
        setup() {
            let idNumber = ref(null);
            let idCard = ref(null);
            return {
                idNumber,
                idCard
            }
        },
        created() {
            // this.exam = this.getStore("selectExam");
            // //  如果没有选择考试,则跳转到考试选择界面
            // if (!this.exam) {
            //     this.$router.push("/");
            // }
            this.reset();
        },
        methods: {
            //  重置
            async reset() {
                let loginUser = await this.getStore("loginUser");
                this.idCard.value = loginUser && loginUser.mobile ? loginUser.mobile: "";
                this.idNumber.value = loginUser && loginUser.idNo ? loginUser.idNo : "888888888888888888";
            },
            //  登录
            joinExam() {
                if (!this.idCard.value) {
                    alert("请输入准考证号");
                    return false;
                }
                // if (!isIdCard(this.idNumber.value)) {
                //     alert("身份证号码错误!");
                //     return false;
                // }

                if(!this.idNumber.value){
                    alert("请输入证件号码");
                    return false;
                }

                //  设置当前学生的准考证号码和身份证号码
                this.setStore("idCard", this.idCard.value);
                this.setStore("idNumber", this.idNumber.value);
                this.$router.push("/agreement");
            },
        }
    };

</script>

<style src="@/assets/static/login.css" scoped/>
<style lang="stylus" rel="stylesheet/stylus">

</style>
